package com.crawler.harbour.dto;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;


/**
 * 海天、海润根据箱号  查询费用
 *
 * @author wbsheng
 * @create 2018-04-22 14:20
 **/
public class TerminalCostDto {

    /**
     * 箱号
     */
    private String containerNo;
   
    private String portNo;
    private String id;
    private String ladingBillNo;
    private String outDate;
    private String storageDays;
    private String total;
    private String result;
    private List<Fee> feeList=new ArrayList<Fee>();
 
    
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getContainerNo() {
		return containerNo;
	}

	public void setContainerNo(String containerNo) {
		this.containerNo = containerNo;
	}

    public String getLadingBillNo() {
		return ladingBillNo;
	}

	public void setLadingBillNo(String ladingBillNo) {
		this.ladingBillNo = ladingBillNo;
	}

	public String getTotal() {
        return total;
    }

    public void setTotal(String total) {
        this.total = total;
    }   
    
    public List<Fee> getFeeList() {
		return feeList;
	}

	public void setFeeList(List<Fee> feeList) {
		this.feeList = feeList;
	}

	public String getPortNo() {
		return portNo;
	}

	public void setPortNo(String portNo) {
		this.portNo = portNo;
	}

	public String getResult() {
		return result;
	}

	public void setResult(String result) {
		this.result = result;
	}

	public String getOutDate() {
		return outDate;
	}

	public void setOutDate(String outDate) {
		this.outDate = outDate;
	}

	public String getStorageDays() {
		return storageDays;
	}

	public void setStorageDays(String storageDays) {
		this.storageDays = storageDays;
	}



	DecimalFormat df = new DecimalFormat("0.###");
	public void addFee(String feeCode,String feeValue) {
		
		
		if(feeValue!=null&&feeValue.trim().length()!=0&&!feeValue.trim().equals("0")&&feeValue.trim().matches("^\\d+(\\.\\d+)?$")) {
			BigDecimal fee = new BigDecimal(feeValue.trim());
			
			for(Fee originalFee:feeList) {
				if(originalFee.getCostCode().equals(feeCode)) {
					BigDecimal newFee = new BigDecimal(df.format(originalFee.getFee())).add(fee);
					originalFee.setFee(newFee.doubleValue());
					return;
				}
			}
			
			this.feeList.add(new Fee(feeCode, Double.valueOf(feeValue.trim())));
						
		}
	}

    @Override
    public String toString() {
        return "HTRTFeeDto{" +
                "containerNo='" + containerNo + '\'' +
                ", ladingBillNo='" + ladingBillNo + '\'' +
                ", portNo='" + portNo + '\'' +
                ", feeList='" + feeList + '\'' +
                ", total='" + total + '\'' +
                '}';
    }
}
